//
//  CNProfileSummary.swift
//  SwiftUi
//
//  Created by xm on 03/09/2025.
//

import SwiftUI


struct CNProfileSummary: View {
    
    var profile:User
    
    var dateFormatter : DateFormatter {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy年MM月dd日 HH:mm:ss"
        return dateFormatter
    }
    
    var body: some View {
        withUnsafePointer(to: profile) { pointer in
            print("[CNProfileSummary] profile", pointer)
        }
        
        

        
        return List {
        
            Text(profile.username).font(.title).bold()
            Text("允许通知：\(profile.prefersNotifications ? "是" : "否" )")
            Text("喜欢的季节：\(profile.prefersSeason.rawValue )")
            Text("生日：\(dateFormatter.string(from: profile.birthday) )")
            VStack(alignment: .leading) {
                Text("最近的徒步旅行").font(.headline)
                HikeView(hike: hikes[0])
                
            }
            
            
        }.listStyle(.plain)
    }
}

#Preview {
    CNProfileSummary(profile: User.default)
}
